﻿using Rhino.Geometry;
using ArchiToolkit.Grasshopper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace CGAL.Grasshopper.Wrapper;

static class Polygon2D
{
    [DocObj]
    [ObjNames("Polygon2D", "Polygon2D", "Creates a 2D polygon.")]
    public static IntPtr Create(List<Point3d> PointArray)
    {
        var Point2DArray = new double[PointArray.Count * 2];
        for (var i = 0; i < PointArray.Count; i++)
        {
            Point2DArray[i * 2] = PointArray[i].X;
            Point2DArray[i * 2 + 1] = PointArray[i].Y;
        }
        var polygon2D = IntPtr.Zero;
        UnsafeNativeMethods.Polygon2D_Create(Point2DArray, (ulong)Point2DArray.Length, ref polygon2D);
        return polygon2D;
    }
}


